If you cancel a Job, it cancels all of its child jobs and waits for all of them to complete their cancellation.

However, as was noted before, cancellation is cooperative. Simple Kotlin statements, like println(), will not pay attention to whether their job was cancelled. As a result, if you run this snippet, you will see the "This is executed after canceling the parent" message, even though the parent is canceling this child job. However, delay() will honor the cancellation request, so we do not see any messages after that point.

You can learn more about this in:
Tags:
Run Edit